import './index.scss'
import { useMount } from 'ahooks'

import { lazy, Suspense, useState } from 'react'

import { initWindwoData } from '../Utils/Common'
import { GetIndexedDB } from '../Utils/IndexedDB'

const StartIndex = () => {
    const [Template, setTemplate] = useState()

    useMount(async () => {
        const config = await GetIndexedDB('config')
        initWindwoData(config)
        const { client_id } = config
        const Index = lazy(() => import(`./${client_id}/index.jsx`))

        // 路由分发
        // 判断用户权限


        setTemplate(Index)
    })

    if (Template) {
        return (
            <Suspense>
                <div className='StartPage' style={{ '--theme': 'red' }}>
                    <Template />
                </div>
            </Suspense>
        )
    }
}


export default StartIndex;